package com.tancire.web.controller.platform.system;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tancire.common.annotation.Log;
import com.tancire.common.core.controller.BaseController;
import com.tancire.common.core.domain.AjaxResult;
import com.tancire.common.enums.BusinessType;
import com.tancire.system.domain.SysUserQuick;
import com.tancire.system.service.ISysUserQuickService;
import com.tancire.common.utils.poi.ExcelUtil;
import com.tancire.common.core.page.TableDataInfo;

/**
 * 快捷菜单Controller
 *
 * @author tancire
 * @date 2024-06-15
 */
@RestController
@RequestMapping("/system/sysUserQuick")
public class SysUserQuickController extends BaseController {
    @Resource
    private ISysUserQuickService sysUserQuickService;

    /**
     * 查询快捷菜单列表
     */
    @PreAuthorize("@ss.hasPermi('system:sysUserQuick:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserQuick sysUserQuick) {
        startPage();
        List<SysUserQuick> list = sysUserQuickService.selectSysUserQuickList(sysUserQuick);
        return getDataTable(list);
    }

    /**
     * 查询我的快捷菜单列表
     *
     */
    @PreAuthorize("@ss.hasPermi('system:sysUserQuick:mine')")
    @GetMapping("/mine/list")
    public AjaxResult mineList(SysUserQuick sysUserQuick) {
        List<SysUserQuick> list = sysUserQuickService.selectMineQuickList(sysUserQuick);
        return AjaxResult.success("查询成功", list);
    }

    /**
     * 导出快捷菜单列表
     */
    @PreAuthorize("@ss.hasPermi('system:sysUserQuick:export')")
    @Log(title = "快捷菜单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUserQuick sysUserQuick) {
        List<SysUserQuick> list = sysUserQuickService.selectSysUserQuickList(sysUserQuick);
        ExcelUtil<SysUserQuick> util = new ExcelUtil<SysUserQuick>(SysUserQuick.class);
        util.exportExcel(response, list, "快捷菜单数据");
    }

    /**
     * 获取快捷菜单详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sysUserQuick:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(sysUserQuickService.selectSysUserQuickById(id));
    }

    /**
     * 新增快捷菜单
     */
    @PreAuthorize("@ss.hasPermi('system:sysUserQuick:add')")
    @Log(title = "快捷菜单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserQuick sysUserQuick) {
        return toAjax(sysUserQuickService.insertSysUserQuick(sysUserQuick));
    }

    /**
     * 修改快捷菜单
     */
    @PreAuthorize("@ss.hasPermi('system:sysUserQuick:edit')")
    @Log(title = "快捷菜单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserQuick sysUserQuick) {
        return toAjax(sysUserQuickService.updateSysUserQuick(sysUserQuick));
    }

    /**
     * 删除快捷菜单
     */
    @PreAuthorize("@ss.hasPermi('system:sysUserQuick:remove')")
    @Log(title = "快捷菜单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysUserQuickService.deleteSysUserQuickByIds(ids));
    }
}
